<html>
<head>
<script type="text/javascript" src="gears_init.js"></script>
<script type="text/javascript" src="calgears.js"></script>
<script>
  var db;

  function load() {
    getEvents();
    init();
    createStore();
    setupDatabase();
  }

  function listEvents(root) {
    var feed = root.feed;
    var html = [];
    html.push('<ul>');
    for (var i = 0; i < feed.entry.length; i++) {
      var entry = feed.entry[i];
      var title = entry.title.$t;
      if (entry.gd$when) {
        var date = entry.gd$when[0].startTime;
      } else {
        var date = "N/A";
      }
      html.push('<li>', title, ': ', date, '</li>');
    }
    html.push('</ul>');
    document.getElementById("agenda").innerHTML = html.join("");
  }

  function getEvents() {
    var script = document.createElement("script");
    script.src = "http://www.google.com/calendar/feeds/pamela.fox%40gmail.com/public/full?alt=json-in-script&callback=listEvents";
    document.body.appendChild(script);
  }

</script>
</head>
<body onload="load()">
<h3>Events:</h3>

<div id="agenda"></div>


<span id="textOut" style="color: red;"></span>
</body>
</html>
